/**
 * Copyright (c) Chris Myers 2007
 * May 29, 2007
 */
package com.chrisandjo.rostra.domain;

import static com.googlecode.instinct.expect.Expect.expect;
import com.googlecode.instinct.integrate.junit4.InstinctRunner;
import com.googlecode.instinct.marker.annotate.BeforeSpecification;
import com.googlecode.instinct.marker.annotate.Specification;
import com.googlecode.instinct.marker.annotate.Subject;
import org.junit.runner.RunWith;

import java.util.HashSet;
import java.util.Set;

/**
 * @author Chris
 */
@RunWith(InstinctRunner.class)
public class ATaskWithNoPeople {
    @Subject private Task task;

    @BeforeSpecification
    public void setUp() {
        task = new TaskEntity("2007-12-05");
    }

    @Specification
    public void mustSaveDateInTheConstructor() {
        expect.that(new TaskEntity("2007-03-03").getDate()).isEqualTo("2007-03-03");
    }

    @Specification
    public void mustHaveNoPeople() {
        expect.that(task.getPeople()).isEmpty();
    }

    @Specification
    public void mustNotBeEmptyWhenAPersonIsAdded() {
        final Person person = new PersonEntity("Phil");
        Set<Person> onePerson = new HashSet<Person>() {
            {
                add(person);
            }
        };
        task.addPeople(onePerson);
        expect.that(task.getPeople()).isNotEmpty();
        expect.that(task.getPeople()).containsItem(person);
    }

}
